<template>
  <g-details :detailData="inputData" :inputConfig="inputConfig" :rules="rules" @pop="setdata" ref="detail"> </g-details>
</template>

<script>
import baseMixin from "@/mixins/BaseMixin";
export default {
  name: "dispatchDetails",
  mixins: [baseMixin],
  props: {
    inputData: {
      type: Object,
    },
  },
  data() {
    return {
      rules: {
        deliveryDeptName: [
          { required: true, message: this.$selectPlease('model.deliveryDept'), trigger: "blur" },
        ],
        materialType:[
          { required: true, message: this.$selectPlease('model.materialType'), trigger: "blur" },
        ],
        deliveryType:[
          { required: true, message: this.$selectPlease('model.deliveryType'), trigger: "blur" },
        ],
      },
    };
  },
  computed: {
    inputConfig() {
      return [
        {
          type: "input",
          label: "包装或器具编号",
          props: "code111",
        },
        {
          type: "input",
          label: "内部尺寸-长",
          break: true,
          props: "deliveryTime",
        },
        {
          type: "select",
          label: "出厂包装类型",
          options:this.getOptions('/codeLookup/DeliveryType'),
          props: "deliveryStatus",
        },
        {
          type: "input",
          label: "内部尺寸-宽",
          props: "deliveryType",
          break: true,
        },
        {
          type: "input",
          label: "一次/多次使用",
          props: "materialType",
          disabled: true,
        },
        {
          type: "input",
          label: "内部尺寸-高",
          props: "materialType",
          break:true,
        },
        {
          type: "input",
          label: "包装单元重量",
          props: "totalRows",
        },
        {
          type: "input",
          label: "运输周期",
          props: "materialType",
          break:true,
        },
        {
          type: "input",
          label: "外部尺寸-长",
          props: "totalRows",
        },
        {
          type: "input",
          label: "计划运输车辆",
          props: "materialType",
          break:true,
        },
        {
          type: "input",
          label: "外部才尺寸-宽",
          props: "totalRows",
        },
        {
          type: "input",
          label: "每最小包装存放数",
          props: "materialType",
          break:true,
        },
        {
          type: "input",
          label: "外部才尺寸-高",
          props: "totalRows",
        },
        {
          type: "input",
          label: "特殊包装说明",
          props: "materialType",
          break:true,
        },
        {
          type: "input",
          label: "包装材料/内衬说明",
          props: "totalRows",
        },
      ];
    },
  },
  methods: {
    setdata(data, close, prop) {
      if (prop == 'deliveryDeptName') {
        this.inputData.deliveryDeptName = data.deptName;
        this.inputData.deliveryDeptId = data.id;
        const index = this.inputConfig.findIndex(item => item.props == 'deliveryMklineNo');
        this.inputConfig[index].url = `/baFactoryDeptLine/selectBaFactoryDeptLineList/${data.id}`
      }else if(prop == 'deliveryMklineNo'){
        this.inputData.deliveryDeptName = data.deptName;
        this.inputData.deliveryDeptId = data.deptId;
        this.inputData.deliveryMklineNo = data.deptLineNo;
        this.inputData.deliveryMklineName = data.deptLineName;
      }
      close(false);
    },
    validate(){
      return this.$refs.detail.$refs.from.validate()
    }
  },
  mounted() { }
};
</script>

<style scoped>

</style>
